part of _;

extension on MainPage_Home_Suggest {
  Future<void> controller_initData(bool isAdd) async {
    page = isAdd ? page + 1 : 1;
    return yPost<ShouYeTJModel>(IFinal.Jkids.getHomeTJData, {
      "page": page,
    }, (isSuccess, results, code, message) {
      page = isSuccess ? (isAdd ? (results!.first.productItems.isEmpty ? page - 1 : page) : page) : (isAdd ? page - 1 : page);
      if (isSuccess) {
        if (!isAdd)
          model = results!.first;
        else
          model!.productItems.addAll(results!.first.productItems);
        setState(() {});
      } else {
        if (!isAdd) yShowBuilder("数据加载失败，是否重试？\n$message", () => controller_initData(isAdd), null, true);
      }
      myRefreshController?.loadFinish();
    }, onModel: (map) => ShouYeTJModel.fromJson(map), showProgress: false, cacheEnable: !isAdd);
  }
}
